{{extend './_layouts/home.html'}}

{{block 'title'}}{{'多人博客 - 首页'}}{{/block}} 
{{block 'body'}}
<section class="container">
    <ul class="media-list" id="commentsList">
        {{each comments}}
        <li class="media">
            <div class="media-left">
                <a href="/viewUser?user_id={{ $value.author.authorId }} ">
                    <img style="border-radius: 50%;margin-right: 10px;" width="40" height="40" class="media-object" src="/public/img/avatar-max-img.png" alt="">
                </a>
            </div>
            <div class="media-body">
                <a href="/viewComment?comment_id={{ $value.id }}" title="点击查看文章详情">
                    <h4 style="width:500px" class="media-heading">{{ $value.title }}</h4>
                </a>
                <a href="/viewComment?comment_id={{ $value.id }}" title="点击查看文章详情">
                    <h5  style="width:500px" class="media-heading">{{ $value.message}}</h5>
                </a>
                <p>发布者:
                    <a href="/viewUser?user_id={{ $value.author._id }}">{{ $value.author.authorName }}</a>
                    · {{ $value.replys.length }}个回复 
                    · {{ $value.read.length }}次浏览 
                    · {{ $value.like.length }}人觉得赞
                    · {{ $value.createTime }}
                </p>
            </div>
        </li>
        {{ /each }}
    </ul>
</section>
<!-- <script src="/node_modules/jquery/dist/jquery.js"></script>
<script src="/node_modules/vue/dist/vue.js"></script>
<script src="/node_modules/vue-resource/dist/vue-resource.js"></script>
<script>
    var vm = new Vue({
        el:'#commentsList',
        data:{
            comments:[]
        },
        methods:{
            getComments(){
                this.$http.get('getComments').then(function(data){
                    console.log(data);
                    
                    this.comments = data.body
                    console.log(this.comments);
                })
                // $.ajax({
                //     url:'/getComments',
                //     type:'get',
                //     dataType:'json',
                //     data:'',
                //     success:function(data){
                //         console.log(data);
                        
                //     }
                // })
            }
        },
        mounted(){
            this.getComments()

        }
    })
</script> -->

{{/block}}